const Score = require("../models/score");

//添加积分记录
exports.add = async function(userId,num,content){
    return Score.create({
        userId,
        num,
        content,
    })
}

//获取积分记录
exports.getList = async function(size,page,userId){
    size = parseInt(size);
    page = parseInt(page);
    const {rows,count} = await Score.findAndCountAll({
        where:{
            userId,
        },
        attributes:{exclude:['updatedAt']},
        limit:size,
        offset:(page-1)*size,
        order: [['createdAt', 'DESC']],
    });
    
    return {
        rows,count
    }
}


